﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string constr = "server=.;database=chou;uid=sa;pwd=123456a";
            SqlConnection sc = new SqlConnection(constr);
            string Tsql = "select * from Userinfo";
            SqlCommand scmd = new SqlCommand(Tsql, sc);
            sc.Open();
            var read = scmd.ExecuteReader();
            Console.WriteLine("{0}\t{1}\t{2}\t{3}", "学号", "姓名", "性别", "籍贯");

            while (read.Read())
            {
                Console.WriteLine("{0}\t{1}{2}\t{3}", read["StuID"], read["StuName"], read["StuSex"], read["StyAdd"]);
            }
            sc.Close();
        }
    }
}
